using System;
using System.Collections.Generic;
using Castle.ActiveRecord;

namespace IronMis2.Models
{
    [ActiveRecord("income")]
    public class Income : ActiveRecordBase<Income>
    {
        private Department department;
        private Employee employee;
        private Guid id;
        private string incomeAccount;
        private DateTime? incomeDate;
        private string incomeID;
        private decimal incomeTotal;
        private IList<Item> items;
        private string remark;

        [Property(Column = "income_remark", SqlType = "varchar", Length = 50)]
        public string Remark
        {
            set { remark = value; }
            get { return remark; }
        }

        [PrimaryKey(PrimaryKeyType.GuidComb, Column = "id")]
        public Guid Id
        {
            set { id = value; }
            get { return id; }
        }

        [BelongsTo(Column = "dep_id", ForeignKey = "id", Insert = true, Update = true, Fetch = FetchEnum.Select)]
        public Department Department
        {
            set { department = value; }
            get { return department; }
        }

        [BelongsTo(Column = "s_number", ForeignKey = "id", Insert=true, Update=true, Fetch = FetchEnum.Select)]
        public Employee Employee
        {
            set { employee = value; }
            get { return employee; }
        }

        [Property(Column = "income_id", SqlType = "char", Length = 10)]
        public string IncomeID
        {
            set { incomeID = value; }
            get { return incomeID; }
        }

        [Property(Column = "income_account", SqlType = "char", Length = 19)]
        public string IncomeAccount
        {
            set { incomeAccount = value; }
            get { return incomeAccount; }
        }

        [Property(Column = "income_date", SqlType = "datetime", Length = 8)]
        public DateTime? IncomeDate
        {
            set { incomeDate = value; }
            get { return incomeDate; }
        }

        [Property(Column = "income_total", SqlType = "decimal", Length = 9)]
        public decimal IncomeTotal
        {
            set { incomeTotal = value; }
            get { return incomeTotal; }
        }

        [HasMany(Lazy = true, Inverse = true, Cascade = ManyRelationCascadeEnum.AllDeleteOrphan)]
        public IList<Item> Items
        {
            set { items = value; }
            get { return items; }
        }
    }
}